<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>选择店铺</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-header">请选择需要操作的店铺</div>

<div class="zz-store-list">
    <ol>
        <!--<li>
            <span class="zz-store">西直门店</span>
            <span class="zz-select zz-pathnot zz-path"></span>
        </li>-->
    </ol>
</div>
<input class="footer bg zz-footTop" type="button" value="确认">
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript">
	var queryURLParameter = utils.queryURLParameter();
	var data = '';

    var $store_list = $(".zz-store-list ol");
    function bindHTML() {
        var str = "";
        for (var i = 0; i < data.length; i++) {
            var curData = data[i];
            str += '<li>';
            str += '<span class="zz-store" storeId="' + curData["storeId"] + '" merId="' + curData["merId"] + '" toreShortName="' + curData["storeShortName"] + '">' + curData["storeShortName"] + '</span>';
            curData["defultStore"] == 0 ? str += '<span class="zz-select zz-pathnot zz-path"></span>' : str += '<span class="zz-select zz-pathnot"></span>';
            str += '</li>'
        }
        $store_list.html(str);
    }
    //初始化店铺
    $.ajax({
        url: utils.ajaxUrl()+"h5/store/receiver/getStoreByOpenid",
        async: false,
        type: 'get',
        success: function (res) {
        	//console.log(res);
        	var res = JSON.parse(res);
        	//console.log(res);
            if (res && res.retCode == '0000') {
                data = res["storeList"];
                bindHTML()
            }else{
                new $.modal({
                    content: res.retMsg,//弹框内容
                    showcontent: true,//false为弹出框组件二，true为弹出框组件一
                }).show();
                $(".footer").attr("disabled","true");
            }
        }
    });
</script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript">

    $(".zz-store-list ol li").click(function () {
        $(this).find(".zz-select").addClass("zz-path");
        $(this).siblings().find(".zz-select").removeClass("zz-path");
    });
    
    $footer.click(function () {
	    var $path=$(".zz-path");
	    var storeId = $path.siblings().attr("storeId");
	    var merId = $path.siblings().attr("merId");
	    var toreShortName = $path.siblings().attr("toreShortName");
	    localStorage.setItem("storeId", storeId);
    	window.location.href = "../../html/h5/cashierAdmin.html?storeId=" + storeId + "&toreShortName=" + toreShortName;
    })

</script>
</html>